<?php 
header("Content-Type:text/html;charset=utf-8");
include 'includes/init.php';
include_once 'includes/upload.class.php';

session_start();

$id=isset($_SESSION['id'])?$_SESSION['id']:'';
$nphone = isset($_SESSION['phone']) ? $_SESSION['phone'] : '';
$uesrname = isset($_SESSION['uesrname']) ? $_SESSION['uesrname'] : '';
$time = time();


// 具体项目数据
if(!empty($_GET['project'])){
	$project = $_GET['project'];
	$code = $_GET['code'];
	$sql ="select e.*,m.company_name from t_examine as e, t_member as m  where e.auditing = 0 and e.project = '".$project."' and e.company_data = m.company_data and e.code = '".$code."' ";
	$infoAll = $db_Obj->getall($sql);
	
	// 对比旧数据 旧数据与提交数据对比删除旧数据的重复部分.
 	$sql = "SELECT
		    m.company_name,
		    m.company_data,
		    p.mid,
		    p.nphone,
		    p.project,
		    p.status,
		    p.price_type,
		    p.lasttime,
		    p.units,
		    p.currency,
		    p.number,
		    p.material,
			p.purchase,
			p.plant,
			p.extranum,
		    b.price,
		    b.btype,
		    b.bsize,
		    b.delivery,
		    b.MOQ,
		    b.MPQ,
		    b.createtime,
		    b.bnumber,
		    b.rate,
		    b.id
		FROM
		    t_bid AS b,
		    t_member AS m,
		    t_product AS p
		WHERE
		(
				p.mifeng = 0 
				AND p.project = '".$project."'
				AND b.mid = m.id
				AND p.type = b.btype
			)
		OR (
			p.mifeng = 1
			AND p.lasttime < ".$time."
			AND p.project = '".$project."'
			AND b.mid = m.id
			AND p.type = b.btype
		)	
		ORDER BY p.type asc, b.price asc
		";
	$infoAll_bid = $db_Obj->getall($sql);
	foreach ($infoAll as $k_a => $v_a) {
		foreach ($infoAll_bid as $k_b => $v_b) {
			if($v_a['bid_id'] == $v_b['id']){
				unset($infoAll_bid[$k_b]);
			}			
		}
	}
	$new_infoAll = array_merge($infoAll, $infoAll_bid);


	$sql = "
	SELECT
	DISTINCT l.opinion,
	l.*, m. names
FROM
	t_exa_log AS l,
	t_examine AS e,
	t_member AS m
WHERE
	l. CODE = e. CODE
AND e.mid = m.id
AND l.project = '".$project."'
AND l. CODE = '".$code."'
	";
	// echo $sql;
	$exa_data = $db_Obj->getall($sql);
	// var_dump($exa_data);
}

include 'ok-pro-detail.html';

 ?>